Move the actual call routed by do_legacy_api_with_uuid out of the scope of
authorEwan Mellor <ewan@xensource.com>
Wed, 6 Dec 2006 10:12:39 +0000 (10:12 +0000)
committerEwan Mellor <ewan@xensource.com>
Wed, 6 Dec 2006 10:12:39 +0000 (10:12 +0000)
the domains_lock.  The call itself is already locking as necessary, and it
is important for domain_start to be able to release the lock across the scope
of waitForDevices.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/XendDomain.py

index cc3c5c783ee778506d1965858335ab698c96cf7e..4b116344035eee92ed1b1520bc2c8f4873325096 100644 (file)
@@ -641,17 +641,22 @@ class XendDomain:
         return (self.get_vm_with_dev_uuid(klass, dev_uuid) != None)
 
     def do_legacy_api_with_uuid(self, fn, vm_uuid, *args, **kwargs):
+        dom = self.uuid_to_dom(vm_uuid)
+        fn(dom, *args, **kwargs)
+
+    def uuid_to_dom(self, vm_uuid):
         self.domains_lock.acquire()
         try:
             for domid, dom in self.domains.items():
-                if dom.get_uuid == vm_uuid:
-                    return fn(domid, *args, **kwargs)
+                if dom.get_uuid() == vm_uuid:
+                    return domid
                     
             if vm_uuid in self.managed_domains:
                 domid = self.managed_domains[vm_uuid].getDomid()
-                if domid == None:
-                    domid = self.managed_domains[vm_uuid].getName()
-                return fn(domid, *args, **kwargs)
+                if domid is None:
+                    return self.managed_domains[vm_uuid].getName()
+                else:
+                    return domid
             
             raise XendInvalidDomain("Domain does not exist")
         finally: